package com.lovi.io_;

import java.io.*;

/**
 * 实现二进制文件的拷贝
 */
public class BufCopy2 {
    public static void main(String[] args) throws IOException {
        BufferedInputStream bi = new BufferedInputStream(new FileInputStream("D:\\桌面\\test1.png"));
        BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream("D:\\桌面\\test2.png"));
        String line;
        //边读边写
        int readlen = 0;
        byte[] bytes = new byte[1024];
        while ((readlen = bi.read(bytes))!=-1){
            bo.write(bytes,0,readlen);
        }

        System.out.println("二进制文件拷贝完毕...");
        bi.close();
        bo.close();
    }
}
